#include "stdafx.h"
#include "CombatCalculatorImp.h"
#include "Combat/CombatSysIf.h"
#include "Combat/CombatSkill.h"
#include "Combat/CombatDefinition.h"
#include "Entity/EntityIf.h"


bool CombatCalculatorStandard::doCalc(CombatSkill& ab, ICombatSys& c, ICombatSys& t, CombatResult& r)
{
	if (ab.m_nDamage>0)
	{
		return doCalcDamage(ab, c, t, r);
	}
	else if (ab.m_nDamage==0)
	{
		r.m_nResult = CombatResult::Succeed;
		r.m_nHPAffected = 0;
		r.m_bHasGene = false;
		r.m_bCriticalHit = false;
		return true;
	}
	else
	{
		return doCalcHeal(ab, c, t, r);
	}
}


bool CombatCalculatorStandard::doCalcDamage(CombatSkill& ab, ICombatSys& c, ICombatSys& t, CombatResult& r)
{
	/*if (t.hasImmunity(ab.m_nElement))
	{
		r.m_nResult = CombatResult::Immuned;
		return true;
	}

	if (c.getToHit(ab) > t.getToDodge(ab))
	{
		int nDamage = 0;
		if (c.getToCritical(ab)>0)
		{
			nDamage = c.getToAttack(ab) * 3 - t.getToDefense(ab);
			r.m_bCriticalHit = true;
		}
		else
		{
			nDamage = c.getToAttack(ab) - t.getToDefense(ab);
			r.m_bCriticalHit = false;
		}

		if (nDamage<=0)
		{
			r.m_nHPAffected = -1;
		}
		else
		{
			r.m_nHPAffected = -nDamage;
		}
		return true;
	}
	else
	{
		r.m_nResult = CombatResult::Miss;
		return true;
	}*/
	return true;
}

bool CombatCalculatorStandard::doCalcHeal(CombatSkill& ab, ICombatSys& c, ICombatSys& t, CombatResult& r)
{
	r.m_nResult = CombatResult::Succeed;
	//
	//	Damage is the ratio on spirit

	r.m_bHasGene = false;
	r.m_bCriticalHit = false;

	return true;
}